<include file="Public/head" />

<body class="no-skin">
    <include file="Public/header" />
    <div class="main-container" id="main-container">
        <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {}
        </script>
        <include file="Public/sidebar" />
        <div class="main-content">
            <div class="main-content-inner">
                <!-- #section:basics/content.breadcrumbs -->
                <include file="Public/breadcrumbs" />
                <!-- /section:basics/content.breadcrumbs -->
                <div class="page-content">
                    <include file="Public/set" />
                    <!-- /section:settings.box -->
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="row">
                                <form class="form-inline" action="" method="get">
                                    <a class="btn btn-success btn-sm" href="{:U('add')}" value=""> <i class="fa fa-plus"></i> 新增</a>
                                </form>
                            </div>
                            <!-- PAGE CONTENT BEGINS -->
                            <div class="space-4"></div>
                            <div class="row">
                                <table class="table table-striped table-bordered">
                                    <thead>
                                        <tr>
                                            <th class="col-xs-1">id</th>
                                            <th class="col-xs-5">分类名称</th>
                                            <th class="col-xs-2">操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <empty name="list">
                                            <tr>
                                                <td colspan="3">无分类</td>
                                            </tr>
                                            <else />
                                            <volist name="list" id="vo">
                                                <tr>
                                                    <td>{$vo.ind_id}</td>
                                                    <td>{$vo.ind_name}</td>
                                                    <td>
                                                        <a class="green" href="{:U('update',array('id'=>$vo['ind_id']))}" title="修改"> <i class="ace-icon fa fa-pencil bigger-130"></i> 修改</a>
                                                        <a class="red del" href="{:U('del',array('id'=>$vo['ind_id']))}" title="删除"> <i class="ace-icon fa fa-trash-o bigger-130"></i> 删除</a>
                                                    </td>
                                                </tr>
                                            </volist>
                                        </empty>
                                    </tbody>
                                </table>
                            </div>
                            <!-- PAGE CONTENT ENDS -->
                        </div>
                        <!-- /.col -->
                    </div>
                    <!-- /.row -->
                </div>
                <!-- /.page-content -->
            </div>
        </div>
        <!-- /.main-content -->
        <include file="Public/footer" />
    </div>
    <!-- /.main-container -->
    <include file="Public/footerjs" />
    <!-- inline scripts related to this page -->
    <script type="text/javascript">
    $(function() {
        $(".del").on('click', function() {
            var obj = $(this);
            var id = obj.attr('val');
            bootbox.confirm({
                title: "系统提示",
                message: "是否要删除该分类？",
                callback: function(result) {
                    if (result) {
                        $.get("{:U('del')}?id=" + id, function(result) {
                            if (result == 2) {
                                bootbox.alert({
                                    buttons: {
                                        ok: {
                                            label: '确定',
                                            className: 'btn-myStyle'
                                        }
                                    },
                                    message: '该类下拥有子类，无法删除。',
                                    title: "提示信息",
                                });
                                return;
                            } else if (result == 1) {
                                bootbox.alert({
                                    buttons: {
                                        ok: {
                                            label: '确定',
                                            className: 'btn-danger'
                                        }
                                    },
                                    message: '恭喜，删除成功！',
                                    callback: function() {
                                        window.location.reload(true);
                                    },
                                    title: "友情提示",
                                });
                                return;
                            } else {
                                bootbox.dialog({
                                    message: "抱歉，系统错误，请稍后再试。",
                                    buttons: {
                                        "success": {
                                            "label": "确定",
                                            "className": "btn-danger"
                                        }
                                    }
                                });
                                return;
                            }
                        });
                    } else {
                        return true;
                    }
                },
                buttons: {
                    "cancel": { "label": "取消" },
                    "confirm": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
        })
    })
    </script>
</body>

</html>